package de.preamp.clients.java.utils;

import java.io.IOException;

/**
 * An abstract class for preferences, defining the abstract getter and setter
 * methods for needed preferences and satic fields for global, unchangable
 * preferences.
 * 
 * @author André Stannek
 * @version 2010-03-22
 */
public abstract class AbstractPreferences
{
    /**
     * don't change!
     */
    public static final String LASTFM_API_KEY =
	    "7e71a826383d069396a71e7750efa074";

    /**
     * 
     */
    public static final String LASTFM_API_SECRET =
	    "7b11e09e279d0df2b5f1ffb927909ce6";

    /**
     * Due Preferences should be Singleton, this method delegates to the
     * instance() method of the used implementation. If another implementation
     * should be used change it only here.
     * 
     * @return an {@link AbstractPreferences} object holding the current
     *         preferences used
     */
    public static AbstractPreferences instance()
    {
	return PreferencesInFile.instance();
    }

    /**
     * @return true if necessary configurations are made
     */
    public abstract boolean isConfigured();

    /**
     * @return the lastfmUser
     */
    public abstract String getLastfmUser();

    /**
     * @param lastfmUser
     *            the lastfmUser to set
     * @throws IOException
     *             if preferences file could not be saved
     */
    public abstract void setLastfmUser(String lastfmUser) throws IOException;

    /**
     * @return the lastfmPassword
     */
    public abstract char[] getLastfmPassword();

    /**
     * @param lastfmPassword
     *            the lastfmPassword to set
     * @throws IOException
     *             if preferences file could not be saved
     */
    public abstract void setLastfmPassword(char[] lastfmPassword)
	    throws IOException;

    /**
     * @return the lasftfmScroblingEnabled
     */
    public abstract boolean isScrobblingEnabled();

    /**
     * @param scrobblingEnabled
     *            the lasftfmScroblingEnabled to set
     */
    public abstract void setScrobblingEnabled(boolean scrobblingEnabled);

    /**
     * @return true if system look and feel should be enabled.
     */
    public abstract boolean isSystemLAFEnabled();

    /**
     * @param lafEnabled
     *            true if system look and feel should be enabled.
     */
    public abstract void setSystemLAFEnabled(boolean lafEnabled);

    /**
     * @return the serverURL
     */
    public abstract String getServerURL();

    /**
     * @param serverURL
     *            the serverURL to set
     * @throws IOException
     *             if preferences file could not be saved
     */
    public abstract void setServerURL(String serverURL) throws IOException;

    /**
     * @return the serverUser
     */
    public abstract String getServerUser();

    /**
     * @param serverUser
     *            the serverUser to set
     * @throws IOException
     *             if preferences file could not be saved
     */
    public abstract void setServerUser(String serverUser) throws IOException;

    /**
     * @return the serverPassword
     */
    public abstract char[] getServerPassword();

    /**
     * @param serverPassword
     *            the serverPassword to set
     * @throws IOException
     *             if preferences file could not be saved
     */
    public abstract void setServerPassword(final char[] serverPassword)
	    throws IOException;

    /**
     * @return the downloadPath
     */
    public abstract String getDownloadPath();

    /**
     * @param downloadPath
     *            the downloadPath to set
     */
    public abstract void setDownloadPath(String downloadPath);

    /**
     * @return the cacheSize in kB
     */
    public abstract int getCacheSize();

    /**
     * @param cacheSize
     *            the cacheSize to set in kB
     */
    public abstract void setCacheSize(int cacheSize);
}
